package com.touchapk.core;

import org.luaj.vm2.Globals;
import org.luaj.vm2.LuaFunction;
import org.luaj.vm2.LuaValue;
import org.luaj.vm2.Varargs;
import org.luaj.vm2.lib.jse.JsePlatform;

/**
 * @description
 * @author yangkeyun
 * @email coyun@qq.com
 * @date 2016年7月6日
 * @version V1.0
 */
public class Job {
	
	private  Globals  globals = JsePlatform.standardGlobals();
	
	public Globals getGlobals(){
		return globals;
	}
	public Job(){}
	
	public Thread currentThread(){
		return Thread.currentThread();
	}
	
	public Job(boolean isApp){
		if(isApp){
			globals.get("dofile").call(LuaValue.valueOf("com/touchapk/lua/Events.lua"));
		}
	}
	
	public LuaValue pullScript(String script){
		return globals.load(script).call();
	}
	

	public void pullAndRunLua(String path){
		globals.get("dofile").call(LuaValue.valueOf(path));
	}
	
	public void pullAndRunLua(String path[]){
		for(String p:path){
			globals.get("dofile").call(LuaValue.valueOf(p));
		}
	}
	
}
